
import core.*;
import material.Material;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Random;

public class Test {

    public static void main(String[] args) {
        Frame f=new Frame("cool");
        cdPanel cd=new cdPanel(); //为cdPanel创建实例对象
        f.add(cd);

        f.setLocationRelativeTo(null);
        f.setSize(600,600);
        f.setVisible(true);

        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent arg0) {
                Window window=arg0.getWindow();
                window.dispose();
            }
        });

    }

}

//创建cdPanel类继承Panel类，重写Panel类的paint()方法
class cdPanel extends Panel{
    //重写Panel类的paint()方法
    public void paint(Graphics gl) {

        Color color = Color.blue;
        Material material = new Material(color);

        Geometry geometry = new Geometry();
        Mesh mesh = new Mesh(geometry, material);

        Scene scene = new Scene();
        scene.add(mesh);

        Camera camera = new Camera(30,1,1,1000);
        camera.setPosition(new float[]{5, 8, 35});

        Renderer renderer = new Renderer(gl);
        renderer.render(scene,camera);
    }

}
